package com.away.ymcc.controller;

import com.away.ymcc.constsant.VaildationConstant;
import com.away.ymcc.result.JSONResult;
import com.away.ymcc.service.VerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.Pattern;

/**
 * 验证码
 *
 * @author away
 * @since 2025-07-08
 */
@Valid
@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {
    @Autowired
    private VerifyCodeService verifyCodeService;

    @GetMapping("/sendSmsCode/{phone}")
    public JSONResult sendSmsCode(@PathVariable @Pattern(regexp = VaildationConstant.TEL_REGEX, message = "号码格式错误") String phone) {
        verifyCodeService.sendSmsCode(phone);
        return JSONResult.success();
    }

}
